package com.wangxin.study8.lambda;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author jojo.wang
 * @title: SortTest
 * @projectName study8
 * @description: 排序
 * @date 2019/3/1314:05
 */
public class SortTest {
    public static void main(String[] args) {
        List<String> list = Arrays.asList("aaa","bb","ccccc");

        //1.8之前
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String a, String b) {
                return a.compareTo(b);
            }
        });

        //1.8之后
        Collections.sort(list,(String a,String b)->{
            return a.compareTo(b);
        });

        //简化
        Collections.sort(list,(a,b)->{
            return a.compareTo(b);
        });

        list.sort((a,b)->a.compareTo(b));
    }
}
